/*
 * TranscriptFactory.h
 *
 *  Created on: Apr 15, 2012
 *      Author: desilva
 */

#ifndef TRANSCRIPTFACTORY_H_
#define TRANSCRIPTFACTORY_H_

#include <string>
#include <map>
#include <utility>      //pair

#include "TranscriptParser.h"

/**
 * Factory for TranscriptParser objects (the names are back from when I was
 * going to give you XML).  getStudentList() and getInstance() are the two
 * methods you will use from this.
 */
class TranscriptFactory
{
public:
    /**
     * StudentInfo structure  that contains a couple piececs of information that
     * identify the student.  This is used to get a list of students and to get
     * more information about a particular student.
     */
    struct StudentInfo
    {
        std::vector<std::string> name;
        std::string              studentId;

        /**
         * Provides an easy way to create a StudentInfo object.
         * @param first  the student's first name
         * @param middle  the student's middle name
         * @param last  the student's last name
         * @param studentId  the student's student id.
         */
        StudentInfo(std::string first,
                    std::string middle,
                    std::string last,
                    std::string studentId)
        {
            name.push_back(first);
            name.push_back(middle);
            name.push_back(last);
            this->studentId = studentId;
        }

        /**
         * Provides an easy way to create a StudentInfo object.
         * @param name  the student's name
         * @param studentId  the student's student id.
         */
        StudentInfo(std::vector<std::string> name,
                    std::string              studentId)
        {
            this->name = name;
            this->studentId = studentId;
        }

        /**
         * Provides an easy way to create a StudentInfo object.
         * @param parser  the TranscriptParser to get the student list info from
         */
        StudentInfo(TranscriptParser* transcript)
        {
            transcript->getStudentName(&(this->name));
            this->studentId = transcript->getStudentId();
        }

    };

private:
    static const std::vector<StudentInfo> studentList;

    /**
     * Initializer for the studentList.
     * @return  a list of all student transcripts available.
     */
    static const std::vector<StudentInfo> initStudentList();

private:

    TranscriptFactory();
    virtual ~TranscriptFactory();

public:
    /**
     * Gets an instance of a TranscriptParser (the class that will give you
     * everything you need from the transcript).
     * @param identifier  the student id of the student you wish to get the
     *      transcript of.
     * @return  a newly allocated object (you need to do the clean up) that will
     *      provide transcript information for the requested student, or NULL if
     *      the student cannot be found.
     */
    static TranscriptParser* getInstance(const std::string &identifier);

    /**
     * Gets a list of all students with transcripts available.
     * @return  a list of all students with transcripts available for viewing.
     */
    static const std::vector<StudentInfo> getStudentList();
};

#endif /* TRANSCRIPTFACTORY_H_ */
